//
//  UIBarButtonItem.swift
//  IOS_Mock_WB
//
//  Created by edy on 2024/9/20.
//

import Foundation
import UIKit

extension UIBarButtonItem{
    convenience init(title:String,fontSize:CGFloat=16,target:Any?,action:Selector,isBack:Bool=false){
        let btn = UIButton.CustomComponent_TextButton(title, fontSize: fontSize, normalColor: .darkGray, highlightedColor: .orange)
        
        if isBack{
            let backImageName = "back"
            btn.setImage(UIImage(named: backImageName) , for: UIControl.State(rawValue: 0))
            btn.sizeToFit()
        }
        
        btn.addTarget(target, action:action, for: .touchUpInside)
        // 初始化 UIBarButtonItem 的自定义视图
        self.init(customView: btn)
    }
}
